package com.shidaimanong.demo.calcaver;

import java.util.Arrays;

public class CalcAverage4 {
    public static void main(String[] args) {
        //初始化全班期末考试成绩
        int[] scores = {80, 75, 99, 100, 31, 60, 59, 74, 90, 98};
        //计算总成绩
        int sum = Arrays.stream(scores).sum();
        //计算平均成绩
        double average = (double) sum / scores.length;
        //计算低于平均成绩人数
        long lowerThanAverage = Arrays.stream(scores).filter(score -> score < average).count();
        //打印低于平均成绩人数
        System.out.println("低于平均成绩人数：" + lowerThanAverage);
    }
}
